<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>员工增加列表</h1>
<form action="">
    <input type="text" name="name" placeholder="姓名">
    <input type="text" name="job" placeholder="工作">
    <input type="text" name="sal" placeholder="工资">
    <input type="button"  value="提交按钮(增加)" @click="add()">
</form>
<!--引入Vue和axios-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",//控制元素
        data:{//变量

        },
        methods:{
            add:function (){
                //得到前端页面提交的信息
                let data = new FormData(document.querySelector("form"));
                //发送请求
                axios.post("/insert",data).then(function (){
                    alert("添加成功!");
                    location.href="/";//回到首页
                })
            }
        }


    })
</script>
</body>
</html>